package demo8;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Configuration//标记为配置类
@ComponentScan("demo8")//通知Spring容器去扫描指定包下的类
public class Config {
    @Bean//通知Spring容器，将放回值纳入容器管理
    public Student intiStudent(){
        return new Student();
    }
    @Bean
    public DruidDataSource initDataSource(){
        DruidDataSource ds = new DruidDataSource();
        ds.setUrl("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true");
        ds.setUsername("root");
        ds.setPassword("root");
        ds.setInitialSize(5);
        ds.setMaxActive(30);
        return ds;
    }

}
